﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.ObjectModel;
using DataAccessComponents;
using BusinessLogicLayer;

namespace inzWeb
{
    public partial class ofertaMiasta : System.Web.UI.Page
    {
        string id;
        protected void Page_Load(object sender, EventArgs e)
        {
            pagerGora.pager_PageIndexChanged += new EventHandler(pagerGora_pager_PageIndexChanged);

            //Id kraju podane przez querystring
            id = Request.QueryString["idkraj"];
            if (!IsPostBack)
            {

                uzupelnijListeMiast(id);
            }
        }

        void pagerGora_pager_PageIndexChanged(object sender, EventArgs e)
        {
            
        }

        void pager_pager_PageIndexChanged(object sender, EventArgs e)
        {
            uzupelnijListeMiast(id);
        }

        private void uzupelnijListeMiast(string id)
        {
            if (!string.IsNullOrEmpty(id))
            {
                int idkraj = Convert.ToInt32(id);
                MiastoBL miastoBL = new MiastoBL();
                ObservableCollection<Miasto> listaMiasta = miastoBL.pobierzListe(idkraj);

                pagerGora.bindDataWithPaging<Miasto>(dlListaMiasta, listaMiasta);
                //    pagerDol.bindDataWithPaging<Kraj>(dlListaKraje, listaKraje);
            }

        }
    }
}